<template>
  <div class="flex-app-continer">
    <vxe-modal
      :zIndex='10'
      :showFooter='true'
      title='选择开票项目及优惠政策标识'
      ref='modal1'
      fullscreen
      auto-resize
      @close="closeSearch"
      >
        <projectListCompNew v-if="handlerLife" @rowClick="rowClick"></projectListCompNew>
        <!-- <projectListCompOld></projectListCompOld> -->

      <template v-slot:footer>
        <vxe-button @click="closeSearch" status="info">取消</vxe-button>
        <vxe-button @click="submitSearch" status="primary">确定</vxe-button>
      </template>
    </vxe-modal>

  </div>
</template>
<script>
import { mixin,mixinVariable } from '@/utils/mixin.js'
import { getCodePage } from '@/api/vmsClassifyCode.js';
import projectListCompNew from './projectListCompNew.vue'
// import projectListCompOld from './projectListCompOld.vue'

export default {
  name: 'projectListComp',
  mixins: [mixin,mixinVariable],
  data() {
    return {
      handlerLife:true,
      rowClickRow:null,

      infoFormData:null,
      formData: {
        hbcode:'', //商品和服务税收分类合并编码
        productCode:'',//产品编码
        productName: '', //产品名称
        proname: '', //商品和服务名称
        selectSource: '1', //项目选取来源，1商品及服务名称 2产品名称
        shortName:'' //商品和服务简称
      },


      timer:null
    }
  },
  components: {
    projectListCompNew,
  },
  methods: {
    rowClick(val){
      this.rowClickRow = val;
    },
    getDom(){
      let doms = [...document.getElementsByClassName('vxe-radio--label')]
        if(doms.length >= 1){
          clearInterval(this.timer)
          this.timer = null
        };
        for(let i =0;i<doms.length;i++){
          
          let dom = doms[i];
          if(i==0){
            dom.innerHTML = '单选'
          }else{
            dom.innerHTML = '选择'
          }
          
      }
    },

    // 页面展示完成， 点击保存回传数据。
    async submitSearch(){
      let k = this;
      if(k.rowClickRow==null){
        this.$message({
              type: 'warning',
              message: '请选择开票项目！',
          })
        return
      }

      
      let pname = '*'+k.rowClickRow.sphfwmc+'*'+k.rowClickRow.epsName
      // let pname = this.formData.selectSource=='1' ? '*'+k.selectRow.sphfwfljc+'*'+k.selectRow.sphfwmc : '*'+k.selectRow.sphfwmc+'*'+k.selectRow.productName  //改改改改改
      // this.$emit('selected',{row:k.selectRow, pname:pname, selectSource:this.formData.selectSource});
      this.$emit('selected',{row:k.rowClickRow,pname,selectSource:this.formData.selectSource})
      this.$refs.modal1.close()
      this.closeSearch()
    },
    closeSearch(){
      this.$refs.modal1.close()
      this.handlerLife = false;
      this.$nextTick(()=>{
        this.handlerLife = true;
      })
    },
    show(d) {
      let k = this;
      this.infoFormData = d
      this.rowClickRow = null
      this.$refs.modal1.open()
      this.$nextTick(()=>{
        this.$refs.modal1.maximize()
        this.timer = setInterval(()=>{
          this.getDom()
        },500)

      })
      
      // setTimeout(function(){
      //   k.$refs.xTable1.clearRadioRow()
      //   k.selectRow = null;
        
      // },500)

    }
  },
}
</script>
<style lang="scss">
.flex-app-continer-table-div{
  width: 98vw;
}
.op-area{position: absolute;left: 0;top:0;}
.expand-wrapper {
  padding: 20px;
}
.form-con{width: 900px; margin:0 auto;}
.vxe-form--item-title{max-width: 500px;}
.radio-area{width: 210px; margin:0 auto;position: relative;left:10px;padding-bottom:5px;}
.radio-tit{margin-right:10px;}
.box-tit{margin-bottom:10px;}
.select-area{padding-bottom:100px;margin-top:10px;}
.non-select{color: #F90707;margin-left:20px;}
.select{color: #333;margin-left:20px;}

:v-deep .vxe-table--render-default .vxe-cell--radio .vxe-radio--icon{
  font-size: 16px !important;
}
:v-deep .vxe-table--render-default.size--mini .vxe-cell--radio .vxe-radio--icon {
    font-size: 14px !important;
}

:v-deep .vxe-table--render-default.size--mini .vxe-cell--checkbox .vxe-checkbox--icon, :v-deep .vxe-table--render-default.size--mini .vxe-cell--radio .vxe-radio--icon {
    font-size: 14px;
}

:v-deep .vxe-table--render-default .vxe-cell--radio .vxe-radio--icon {
    font-size: 16px;
}


.vxe-radio--icon .vxe-radio--unchecked-icon{

}
</style>